make maximum digits compile time configurable via MAX_DIGITS and up to 20.
authorTim Janik <timj@gtk.org>
Wed, 20 Jun 2001 04:13:37 +0000 (04:13 +0000)
committerTim Janik <timj@src.gnome.org>
Wed, 20 Jun 2001 04:13:37 +0000 (04:13 +0000)
Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>

        * gtk/gtkspinbutton.c: make maximum digits compile time configurable
        via MAX_DIGITS and up to 20. 5 was just ridiculously small.
        don't use automatic fixed size buffer for printf-ing floats, doubles
        can expand to really _huge_ strings, use g_strdup_printf() instead.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkspinbutton.c
gtk/gtkspinbutton.h

index 7106a7ea5a5bccc2a9bca6197539c5af6912dac1..f5ca6c91073aae532cd181da8c68ccde971831ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkspinbutton.c: make maximum digits compile time configurable
+       via MAX_DIGITS and up to 20. 5 was just ridiculously small.
+       don't use automatic fixed size buffer for printf-ing floats, doubles
+       can expand to really _huge_ strings, use g_strdup_printf() instead.
+
 Wed Jun 20 04:28:24 2001  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
index 7106a7ea5a5bccc2a9bca6197539c5af6912dac1..f5ca6c91073aae532cd181da8c68ccde971831ba 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkspinbutton.c: make maximum digits compile time configurable
+       via MAX_DIGITS and up to 20. 5 was just ridiculously small.
+       don't use automatic fixed size buffer for printf-ing floats, doubles
+       can expand to really _huge_ strings, use g_strdup_printf() instead.
+
 Wed Jun 20 04:28:24 2001  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
index 7106a7ea5a5bccc2a9bca6197539c5af6912dac1..f5ca6c91073aae532cd181da8c68ccde971831ba 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkspinbutton.c: make maximum digits compile time configurable
+       via MAX_DIGITS and up to 20. 5 was just ridiculously small.
+       don't use automatic fixed size buffer for printf-ing floats, doubles
+       can expand to really _huge_ strings, use g_strdup_printf() instead.
+
 Wed Jun 20 04:28:24 2001  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
index 7106a7ea5a5bccc2a9bca6197539c5af6912dac1..f5ca6c91073aae532cd181da8c68ccde971831ba 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkspinbutton.c: make maximum digits compile time configurable
+       via MAX_DIGITS and up to 20. 5 was just ridiculously small.
+       don't use automatic fixed size buffer for printf-ing floats, doubles
+       can expand to really _huge_ strings, use g_strdup_printf() instead.
+
 Wed Jun 20 04:28:24 2001  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
index 7106a7ea5a5bccc2a9bca6197539c5af6912dac1..f5ca6c91073aae532cd181da8c68ccde971831ba 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkspinbutton.c: make maximum digits compile time configurable
+       via MAX_DIGITS and up to 20. 5 was just ridiculously small.
+       don't use automatic fixed size buffer for printf-ing floats, doubles
+       can expand to really _huge_ strings, use g_strdup_printf() instead.
+
 Wed Jun 20 04:28:24 2001  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
index 7106a7ea5a5bccc2a9bca6197539c5af6912dac1..f5ca6c91073aae532cd181da8c68ccde971831ba 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkspinbutton.c: make maximum digits compile time configurable
+       via MAX_DIGITS and up to 20. 5 was just ridiculously small.
+       don't use automatic fixed size buffer for printf-ing floats, doubles
+       can expand to really _huge_ strings, use g_strdup_printf() instead.
+
 Wed Jun 20 04:28:24 2001  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
index 7106a7ea5a5bccc2a9bca6197539c5af6912dac1..f5ca6c91073aae532cd181da8c68ccde971831ba 100644 (file)
@@ -1,3 +1,10 @@
+Wed Jun 20 05:32:05 2001  Tim Janik  <timj@gtk.org>
+
+       * gtk/gtkspinbutton.c: make maximum digits compile time configurable
+       via MAX_DIGITS and up to 20. 5 was just ridiculously small.
+       don't use automatic fixed size buffer for printf-ing floats, doubles
+       can expand to really _huge_ strings, use g_strdup_printf() instead.
+
 Wed Jun 20 04:28:24 2001  Tim Janik  <timj@gtk.org>
 
        * gtk/gtkrange.c (gtk_range_class_init): hum, "adjustment" was a
index 90bc385115818ee297de60d4ea4aa5e2653353f9..73816e7771bdc28e582d35572bba06675938c7ba 100644 (file)
@@ -43,9 +43,9 @@
 #define ARROW_SIZE                         11
 #define SPIN_BUTTON_INITIAL_TIMER_DELAY    200
 #define SPIN_BUTTON_TIMER_DELAY            20
-#define MAX_TEXT_LENGTH                    256
 #define MAX_TIMER_CALLS                    5
 #define EPSILON                            1e-5
+#define        MAX_DIGITS                         20
 
 enum {
   PROP_0,
@@ -221,7 +221,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
                                                      _("Digits"),
                                                      _("The number of decimal places to display"),
                                                      0,
-                                                     5,
+                                                     MAX_DIGITS,
                                                      0,
                                                      G_PARAM_READWRITE));
   
@@ -1451,11 +1451,11 @@ gtk_spin_button_default_input (GtkSpinButton *spin_button,
 static gint
 gtk_spin_button_default_output (GtkSpinButton *spin_button)
 {
-  gchar buf[MAX_TEXT_LENGTH];
+  gchar *buf = g_strdup_printf ("%0.*f", spin_button->digits, spin_button->adjustment->value);
 
-  sprintf (buf, "%0.*f", spin_button->digits, spin_button->adjustment->value);
   if (strcmp (buf, gtk_entry_get_text (GTK_ENTRY (spin_button))))
     gtk_entry_set_text (GTK_ENTRY (spin_button), buf);
+  g_free (buf);
   return FALSE;
 }
 
@@ -1547,8 +1547,8 @@ gtk_spin_button_new_with_range (gdouble min,
     digits = 0;
   else {
     digits = abs ((gint) floor (log10 (fabs (step))));
-    if (digits > 5)
-      digits = 5;
+    if (digits > MAX_DIGITS)
+      digits = MAX_DIGITS;
   }
 
   gtk_spin_button_configure (spin, GTK_ADJUSTMENT (adj), step, digits);
@@ -1632,7 +1632,7 @@ gtk_spin_button_get_adjustment (GtkSpinButton *spin_button)
  * @spin_button: a #GtkSpinButton
  * @digits: the number of digits to be displayed for the spin button's value
  * 
- * Set the precision to be displayed by @spin_button. Up to 5 digit precision
+ * Set the precision to be displayed by @spin_button. Up to 20 digit precision
  * is allowed.
  **/
 void
index 1686ea27adc56ca825cb62465d92942ca603add7..b152ec3c386ee9b1629a1f0368862161237aeee0 100644 (file)
@@ -93,7 +93,7 @@ struct _GtkSpinButton
   guint button : 2;
   guint need_timer : 1;
   guint timer_calls : 3;
-  guint digits : 3;
+  guint digits : 10;
   guint numeric : 1;
   guint wrap : 1;
   guint snap_to_ticks : 1;